﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:ui="clr-namespace:Bookvar.UI;assembly=Bookvar.UI">

    <LinearGradientBrush x:Key="TextBoxBackground" EndPoint="1.77,-0.75" StartPoint="0.09,0.93">
        <GradientStop Color="LightGray" Offset="1"/>
        <GradientStop Color="LightGray" Offset="0"/>
    </LinearGradientBrush>

    <Style TargetType="{x:Type TextBox}" x:Key="NameTextBox">
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Padding" Value="8" />
        <Setter Property="Background" Value="{StaticResource TextBoxBackground}" />
        <Setter Property="SpellCheck.IsEnabled" Value="True" />
        <Setter Property="Typography.NumeralStyle" Value="OldStyle" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBoxBase">
                    <Border Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" SnapsToDevicePixels="True">
                        <ScrollViewer Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type TextBox}" x:Key="NameTextBoxLevel1">
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Padding" Value="10" />
        <Setter Property="Background" Value="{StaticResource TextBoxBackground}" />
        <Setter Property="SpellCheck.IsEnabled" Value="True" />
        <Setter Property="Typography.NumeralStyle" Value="OldStyle" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBoxBase">
                    <Border Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" SnapsToDevicePixels="True">
                        <ScrollViewer Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Border}" x:Key="Border">
        <Setter Property="BorderBrush" Value="#feca00" />
        <Setter Property="BorderThickness" Value="2,8,2,2" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="CornerRadius" Value="4" />
    </Style>

    <Style TargetType="{x:Type Border}" x:Key="SelectedBorder">
        <Setter Property="BorderBrush" Value="#FFFE9E00" />
        <Setter Property="BorderThickness" Value="2,8,2,2" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="CornerRadius" Value="4" />
    </Style>

    <Style TargetType="{x:Type Border}" x:Key="BorderLevel1">
        <Setter Property="BorderBrush" Value="#feca00" />
        <Setter Property="BorderThickness" Value="4,10,4,4" />
        <Setter Property="Padding" Value="1,1,1,1" />
        <Setter Property="CornerRadius" Value="6,6,6,6" />
    </Style>

    <Style TargetType="{x:Type Border}" x:Key="SelectedBorderLevel1">
        <Setter Property="BorderBrush" Value="#FFFE9E00" />
        <Setter Property="BorderThickness" Value="4,10,4,4" />
        <Setter Property="Padding" Value="1,1,1,1" />
        <Setter Property="CornerRadius" Value="6,6,6,6" />
    </Style>

    <Style TargetType="{x:Type ui:ResourceItemsControl}">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"
								 VerticalAlignment="Center"
								 HorizontalAlignment="Center"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="toggleChildrenCheckBox"
                         TargetType="{x:Type CheckBox}">

        <Grid Width="14" Height="14" >
            <Ellipse Stroke="#FF000000" Fill="#FFFFFFFF" HorizontalAlignment="Stretch" />
            <Rectangle Name="rect" Fill="#000000" Stroke="#FF000000" Margin="6,3,6,3" />
            <Rectangle Fill="#000000" Stroke="#FF000000" Margin="3,6,3,6" />
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="False">
                <Setter TargetName="rect"
						Property="Visibility"
						Value="Hidden" />
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground"
						Value="{DynamicResource
                                {x:Static SystemColors.GrayTextBrushKey}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Storyboard x:Key="StoryboardTopicMouseEnter">
        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="header" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
            <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFFE9E00"/>
        </ColorAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Key="StoryboardTopicMouseLeave">
        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="header" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
            <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#feca00"/>
        </ColorAnimationUsingKeyFrames>
    </Storyboard>


    <DataTemplate x:Key="mainTopicTemplate" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <Border BorderBrush="#feca00" BorderThickness="5,13,5,5" Padding="1,1,1,1" Margin="0,0,0,0" CornerRadius="7,7,7,7" x:Name="header">
                <StackPanel Orientation="Vertical">
                    <TextBox x:Name="PART_TopicName" FontSize="20" Padding="15,15,15,15" Background="{StaticResource TextBoxBackground}"
						 SpellCheck.IsEnabled="True" Typography.NumeralStyle="OldStyle" />
                    <ui:ResourceItemsControl x:Name="PART_Resources"/>
                </StackPanel>
            </Border>
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Name="MainTopicBeginMouseEnter" Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Name="MainTopicBeginMouseLeave" Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="topicTemplate" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <Border Style="{StaticResource Border}" x:Name="header">
                <StackPanel Orientation="Vertical">
                    <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBox}" />
                    <ui:ResourceItemsControl x:Name="PART_Resources"/>
                </StackPanel>
            </Border>
            <CheckBox x:Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Name="TopicBeginMouseEnter"  Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Name="TopicBeginMouseLeave" Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="selectedTopicTemplate" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <Border Style="{StaticResource SelectedBorder}" x:Name="header">
                <StackPanel Orientation="Vertical">
                    <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBox}" />
                    <ui:ResourceItemsControl x:Name="PART_Resources"/>
                </StackPanel>
            </Border>
            <CheckBox Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="leftTopicTemplate" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <CheckBox x:Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
            <Border Style="{StaticResource Border}" x:Name="header">
                <StackPanel Orientation="Vertical">
                    <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBox}" />
                    <ui:ResourceItemsControl x:Name="PART_Resources"/>
                </StackPanel>
            </Border>
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Name="TopicBeginMouseEnter"  Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Name="TopicBeginMouseLeave" Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="leftSelectedTopicTemplate" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <CheckBox Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />

            <Border Style="{StaticResource SelectedBorder}" x:Name="header">
                <StackPanel Orientation="Vertical">
                    <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBox}" />
                    <ui:ResourceItemsControl x:Name="PART_Resources"/>
                </StackPanel>
            </Border>
        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="topicTemplateLevel1" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <Border Style="{StaticResource BorderLevel1}" x:Name="header">
                <StackPanel Orientation="Vertical">
                    <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBoxLevel1}" />
                    <ui:ResourceItemsControl x:Name="PART_Resources"/>
                </StackPanel>
            </Border>
            <CheckBox x:Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Name="TopicBeginMouseEnter" Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Name="TopicBeginMouseLeave" Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="selectedTopicTemplateLevel1" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <Border Style="{StaticResource SelectedBorderLevel1}" x:Name="header">
                <StackPanel Orientation="Vertical">
                    <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBoxLevel1}" />
                    <ui:ResourceItemsControl x:Name="PART_Resources"/>
                </StackPanel>
            </Border>
            <CheckBox Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="leftTopicTemplateLevel1" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <CheckBox x:Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />

            <Border Style="{StaticResource BorderLevel1}" x:Name="header">
                <StackPanel Orientation="Vertical">
                    <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBoxLevel1}" />
                    <ui:ResourceItemsControl x:Name="PART_Resources"/>
                </StackPanel>
            </Border>
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Name="TopicBeginMouseEnter" Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Name="TopicBeginMouseLeave" Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="leftSelectedTopicTemplateLevel1" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <CheckBox Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />

            <Border Style="{StaticResource SelectedBorderLevel1}" x:Name="header">
                <StackPanel Orientation="Vertical">
                    <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBoxLevel1}" />
                    <ui:ResourceItemsControl x:Name="PART_Resources"/>
                </StackPanel>
            </Border>
        </StackPanel>
    </DataTemplate>
</ResourceDictionary>